package com.yly.common.response;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.logging.Level;
import org.springframework.http.HttpStatus;

/**
 * 异常基础类
 *
 * @author anqinghang
 */
@Getter
@Setter
@ToString
public class BaseException extends RuntimeException {

    private HttpStatus status = HttpStatus.OK;

    private String message = "success";

    private transient Level level = Level.INFO;

    public BaseException() {
    }

    public BaseException(HttpStatus status, Throwable throwable) {
        this.status = status;
        this.level = Level.WARNING;
        this.message = throwable.getMessage() + throwable.getStackTrace().toString();
    }

    public BaseException(HttpStatus status, String message) {
        this.status = status;
        this.message = message;
    }

    public BaseException(HttpStatus status, Level level, String message) {
        this.status = status;
        this.level = level;
        this.message = message;
    }
}
